<?php
defined('IN_MAIN') or exit('Invalid Access!');

function get_stockist_detail_by_id($id){
	global $vars;
	$db=$vars["db"];
	if(strlen($id)){
		$sql="select * from $db->users where id='$id' and is_stockist='y'";
		$user=get_stockist_detail_sql($sql);
	}
	return $user;
}

function get_stockist_detail_by_sid($id){
	global $vars;
	$db=$vars["db"];
	if(strlen($id)){
		$sql="select * from $db->users where sid='$id' and is_stockist='y'";
		$user=get_stockist_detail_sql($sql);
	}
	return $user;
}

function get_stockist_detail_by_username($username){
	global $vars;
	$db=$vars["db"];
	if(strlen($username)){
		$sql="select * from $db->users where username='$username' and is_stockist='y'";
		$user=get_stockist_detail_sql($sql);
	}
	return $user;
}

function get_stockist_detail_by_email($email){
	global $vars;
	$db=$vars["db"];
	if(strlen($email)){
		$sql="select * from $db->users where email='$email' and is_stockist='y'";
		$user=get_stockist_detail_sql($sql);
	}
	return $user;
}

function get_stockist_detail_sql($inSQL){
	$r=mysql_query($inSQL);
	if($r && mysql_num_rows($r)){
		$ru=mysql_fetch_assoc($r);
	}
	return $ru;
}

function get_stockist_detail_by_stockist_code($stockist_code, $id){
	global $vars;
	$db=$vars["db"];
	if(strlen($stockist_code)){
		$sql="select * from $db->users where stockist_code='$stockist_code' and is_stockist='y' and id<>'$id'";
		$user=get_stockist_detail_sql($sql);
	}
	return $user;
}
?>